package com.lyz.myself.service.ServiceImpl;


import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.lyz.myself.mapper.CustomerMapper;
import com.lyz.myself.pojo.Po.Customer;
import com.lyz.myself.service.CustomerService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * @program: myself
 * @Date: 2019/1/10 9:40
 * @Author: Mr.Deng
 * @Description:
 */
@Service
public class CustomerServiceImpl implements CustomerService {

    @Autowired
    CustomerMapper customerMapper;

    /**
     * 所有客户（手机号和姓名）
     */
    @Override
    public PageInfo<Map<String,String>> getAllCustomer(Integer creator_role_id,Integer company_id,int pageNum, int pageSize){
        PageHelper.startPage(pageNum, pageSize);
        List<Map<String,String>> userList = customerMapper.getAllCustomer(creator_role_id,company_id);
        PageInfo<Map<String,String>> page = new PageInfo<>(userList);
        return page;
    }
    /**
     *查询普通用户下客户订单（客户池）
     * @mbg.generated 2019-01-10
     */
    @Override
    public PageInfo<Map<String,String>> selectGeneralCustomer(int pageNum, int pageSize){
        PageHelper.startPage(pageNum, pageSize);
        List<Map<String,String>> userList = customerMapper.selectGeneralCustomer();
        PageInfo<Map<String,String>> page = new PageInfo<>(userList);
        return page;
    }
    /**
     * 我的客户（ 全部 ）
     */
    @Override
    public PageInfo<Map<String,String>> selectCustomer(Map<String,Object> map){
        PageHelper.startPage((Integer)map.get("pageNum"),(Integer)map.get("pageSize"));
        List<Map<String,String>> userList = customerMapper.selectCustomer(map);
        PageInfo<Map<String,String>> page = new PageInfo<>(userList);
     return page;
    }


    /**
     *根据id 删除指定客户
     */
    @Override
    public int deleteCustomer(Integer delete_role_id,Integer company_id,Integer delete_time, List<Integer> list){
        int deleteCustomer = customerMapper.deleteCustomer(delete_role_id,company_id,delete_time,list);
        return deleteCustomer;
    }

    /**
     * 添加客户
     */
    @Override
    public int insertCustomer(Customer customer){
        return customerMapper.insertCustomer(customer);
    }

    /**
     * 修改客户信息
     */
    @Override
    public int upadteCustomer(Customer customer){
        return customerMapper.upadteCustomer(customer);
    }

    /**
     * 根据id查看客户信息
     */
    @Override
    public Map<String,String> getCustomer(Integer customer_id,Integer company_id){
        return customerMapper.getCustomer(customer_id,company_id);
    }

}
